/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */
package com.yami.shop.groupbuy.common.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yami.shop.groupbuy.common.api.dto.ApiGroupSkuDto;
import com.yami.shop.groupbuy.common.utils.GroupActivityUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author LGH
 * @date 2019-08-27 17:55:57
 */
@Data
@TableName("tz_group_activity")
@ApiModel("拼团活动表")
public class GroupActivity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId
    @ApiModelProperty("拼团活动id")
    private Long groupActivityId;

    @ApiModelProperty("店铺id")
    private Long shopId;

    @ApiModelProperty("活动名称")
    private String activityName;

    @ApiModelProperty("商品id")
    private Long prodId;

    @ApiModelProperty("拼团状态(1:启用、2:未启用、0:已失效、-1:删除、3:违规下架、4:平台审核 5:已结束)")
    private Integer status;

    @ApiModelProperty("活动开始时间")
    private Date startTime;

    @ApiModelProperty("活动结束时间")
    private Date endTime;

    @ApiModelProperty("成团有效期时间")
    private Integer groupValidTime;

    @ApiModelProperty("成团人数")
    private Integer groupNumber;

    @ApiModelProperty("商品是否限购")
    private Integer hasMaxNum;

    @ApiModelProperty("限购数量")
    private Integer maxNum;

    @ApiModelProperty("是否模拟成团")
    private Integer hasRobot;

    @ApiModelProperty("活动是否预热")
    private Integer isPreheat;

    @ApiModelProperty("是否开启凑团模式")
    private Long hasGroupTip;

    @ApiModelProperty("拼团价格")
    private Double price;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("更新时间")
    private Date updateTime;

    @TableField(exist = false)
    @ApiModelProperty("活动状态（根据活动时间生成）")
    private Integer activityStatus;

    @TableField(exist = false)
    @ApiModelProperty("商品图片")
    private String prodPic;

    @TableField(exist = false)
    @ApiModelProperty("商品名称")
    private String prodName;

    @TableField(exist = false)
    @ApiModelProperty("商品名称")
    private List<ApiGroupSkuDto> groupSkuList;

    @ApiModelProperty("获取活动状态（活动状态：1:未开始、2:进行中、3:已结束、4:已失效、5:违规下架、6:待审核）")
    public Integer getActivityStatus(){
        return GroupActivityUtil.getActivityStatus(startTime, endTime, status);
    }

}
